package com.yw.wanandroid.ui.v

import android.app.Activity
import android.net.Uri
import android.os.Bundle
import android.util.Log
import android.view.MotionEvent
import android.view.View
import android.widget.MediaController
import android.widget.Toast
import com.example.videolib.IjkVideoView
import com.example.videolib.VideoPlayerListener
import com.yw.wanandroid.R
import com.yw.wanandroid.base.BaseActivity
import com.yw.wanandroid.databinding.ActivityPlayVodieBinding
import tv.danmaku.ijk.media.player.IMediaPlayer
import java.io.File
import tv.danmaku.ijk.media.player.IjkMediaPlayer
import java.lang.Exception


class PlayVideoActivity : BaseActivity<ActivityPlayVodieBinding>() {
    private val TAG = "PlayVideoActivity"

    override fun getLayoutId(): Int {
        return R.layout.activity_play_vodie
    }

    override fun getActivity(): Activity {
        return this
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val file = File(externalCacheDir, "061204aef4f543213d6894e92170905e.mp4")
        Log.d("===========", file.absolutePath)
        Log.d("===========", file.length().toString())
        val controller = MediaController(this) //实例化控制器
        try {
            IjkMediaPlayer.loadLibrariesOnce(null)
            IjkMediaPlayer.native_profileBegin("libijkplayer.so")
        } catch (e: Exception) {
            finish()
        }
        binding.viewOffset.setPathAndLoadData(file.absolutePath)
//        binding.viewOffset.setOnTouchListener { v, event ->
//            Log.d(TAG, "onCreate: " + event.action)
//
//            return@setOnTouchListener false
//        }

    }
}